package top.superflow.flow.inner

import org.springframework.context.ApplicationContext
import top.superflow.core.utils.IdentifiableUtils
import top.superflow.exception.RequestUnsupportedException
import top.superflow.flow.config.ResourceConfig
import top.superflow.flow.config.parse.impl.ResourceConfigParser
import top.superflow.flow.runtime.resource.RuntimeResource
import top.superflow.lang.CollectionUtils

import scala.beans.BeanProperty

class InnerSpringContextResourceParser extends ResourceConfigParser with SpringApplicationContextAware{

  @BeanProperty
  var dependencies : Map[String,Any] = _

  override def parse(resourceConfig: ResourceConfig): RuntimeResource = {
    val applicationContext = getApplicationContext(dependencies)

    val runtimeResource = new InnerSpringRuntimeResource
    runtimeResource.setApplicationContext(applicationContext)
    IdentifiableUtils.copy(resourceConfig, runtimeResource)
    runtimeResource
  }

}
